
package com.putao.album.main;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.AbsListView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.loopj.android.http.RequestParams;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.animation.ObjectAnimator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.putao.album.R;
import com.putao.album.album.ActivityAlbumPhotoSelect;
import com.putao.album.base.BaseFragment;
import com.putao.album.child.ActivityChildAdd;
import com.putao.album.child.ActivityChildConnect;
import com.putao.album.child.ActivityChildDetail;
import com.putao.album.child.bean.Child;
import com.putao.album.child.bean.FamilyItem;
import com.putao.album.eventbus.BasePostEvent;
import com.putao.album.fileupload.FileInfo;
import com.putao.album.fileupload.FileUploadState;
import com.putao.album.main.bean.AlbumListItem;
import com.putao.album.main.bean.RequestAlbumListItem;
import com.putao.album.main.bean.RequestSimpleBabyInfoItem;
import com.putao.album.popupwindow.PtInvitePopupWindow;
import com.putao.album.util.ActivityHelper;
import com.putao.album.util.BitmapHelper;
import com.putao.album.util.CommonUtils;
import com.putao.album.util.HttpRequestUtil;
import com.putao.album.util.Loger;
import com.putao.album.util.PuTaoConstants;
import com.putao.album.util.StringHelper;
import com.putao.album.widget.pulltozoomview.PullToZoomBase;
import com.putao.album.widget.pulltozoomview.PullToZoomListViewEx;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

import de.greenrobot.event.EventBus;


/**
 * Created by yanglun on 15/4/21.
 */
public class HomeFragment extends BaseFragment implements View.OnClickListener, PtInvitePopupWindow.PopupClickListener {

    private PullToZoomListViewEx mListView;
    private HomeFragmentListAdapter mAdapter;

    private Button home_page_header_left_btn, home_page_header_right_btn;
    private Button home_page_header_left2_btn, home_page_header_right2_btn;
    private Button home_page_header_left3_btn, home_page_header_right3_btn;
    //遮挡面板
    private RelativeLayout home_page_cover_panel;
    private RelativeLayout home_page_header2_rl;
    private ProgressBar upload_status_pb;
    private LinearLayout upload_status_ll;
    private TextView upload_status_tv;
    private ImageView home_page_header_icon_iv, home_page_header_icon2_iv;
    private TextView home_page_header_name_tv;
    private ImageView home_page_header_gender_iv;

    private Button empty_add_baby_btn, empty_invite_baby_btn;
    private View emptyView;
    private FrameLayout root_fl;
    private ProgressBar home_page_header_loading_pb;
    private ImageView home_page_header_circle_border;
    private PopupWindow popupwindow;
    private String m_invite_send_msg;
    private String baby_id = PuTaoConstants.DEVAULT_BABY_ID;
    private int mScrollValue;
    private int curPage = 1;
    private View mListHeader;
    private boolean bFirstRefresh = true;
    private int preLast;
    private View mFooterView;
    private LinearLayout home_page_tips;
    private LinearLayout upload_notice_layout;
    private Button home_page_tips_invite_btn;

    @Override
    public int doGetContentViewId() {
        return R.layout.fragment_load_more_list_view;
    }

    @Override
    public void doInitSubViews(View view) {
        super.doInitSubViews(view);
        mFooterView = LayoutInflater.from(mActivity).inflate(R.layout.layout_home_fragment_list_footer, null);

        mListView = (PullToZoomListViewEx) view.findViewById(R.id.listview);

        mListView.setOnPullZoomListener(new PullToZoomBase.OnPullZoomListener() {
                                            @Override
                                            public void onPullZooming(int newScrollValue) {
                                                mScrollValue = newScrollValue;
                                                showLoading();
                                            }

                                            @Override
                                            public void onPullZoomEnd() {
                                                if (mScrollValue < -200) {
                                                    refreshAlbumList();
                                                } else {
                                                    hideLoading();
                                                }
                                            }
                                        }
        );
        mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (firstVisibleItem == 1) {
                    if (home_page_header2_rl.getVisibility() != View.VISIBLE) {
                        ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(home_page_header2_rl, "alpha",
                                0, 1).setDuration(200);
                        alphaAnim.setInterpolator(new LinearInterpolator());
                        alphaAnim.addListener(new Animator.AnimatorListener() {
                            @Override
                            public void onAnimationStart(Animator animation) {
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                home_page_header2_rl.setVisibility(View.VISIBLE);
                            }

                            @Override
                            public void onAnimationCancel(Animator animation) {

                            }

                            @Override
                            public void onAnimationRepeat(Animator animation) {

                            }
                        });
                        alphaAnim.start();

                    }
                } else if (firstVisibleItem == 0) {
                    home_page_header2_rl.setVisibility(View.GONE);
                }


                final int lastItem = firstVisibleItem + visibleItemCount;


                if (lastItem == totalItemCount && bFirstRefresh == false) {
                    if (preLast != lastItem) { //to avoid multiple calls for last item
                        if (curPage != -1) {
                            queryAlbumList();
                            preLast = lastItem;
                        }
                    }
                }

            }
        });


//        DisplayMetrics localDisplayMetrics = new DisplayMetrics();
//        mActivity.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
//        int mScreenHeight = localDisplayMetrics.heightPixels;
//        int mScreenWidth = localDisplayMetrics.widthPixels;
//        AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
//        mListView.setHeaderLayoutParams(localObject);
        mListHeader = mListView.getHeaderView();


        home_page_header_left_btn = (Button) mListHeader.findViewById(R.id.home_page_header_left_btn);
        home_page_header_right_btn = (Button) mListHeader.findViewById(R.id.home_page_header_right_btn);
        home_page_header_left2_btn = (Button) view.findViewById(R.id.home_page_header_left2_btn);
        home_page_header_right2_btn = (Button) view.findViewById(R.id.home_page_header_right2_btn);

        home_page_header_left_btn.setOnClickListener(this);
        home_page_header_right_btn.setOnClickListener(this);
        home_page_header_left2_btn.setOnClickListener(this);
        home_page_header_right2_btn.setOnClickListener(this);

        upload_status_ll = (LinearLayout) mListHeader.findViewById(R.id.upload_status_ll);
        upload_status_pb = (ProgressBar) mListHeader.findViewById(R.id.upload_status_pb);
        upload_status_tv = (TextView) mListHeader.findViewById(R.id.upload_status_tv);
        home_page_header_loading_pb = (ProgressBar) mListHeader.findViewById(R.id.home_page_header_loading_pb);
        home_page_header_circle_border = (ImageView) mListHeader.findViewById(R.id.home_page_header_circle_border);
        home_page_cover_panel = (RelativeLayout) view.findViewById(R.id.home_page_cover_panel);
        home_page_cover_panel.setOnClickListener(this);
        home_page_header2_rl = (RelativeLayout) view.findViewById(R.id.home_page_header2_rl);
        home_page_header_icon_iv = (ImageView) mListHeader.findViewById(R.id.home_page_header_icon_iv);
        home_page_header_icon_iv.setOnClickListener(this);
        home_page_header_icon2_iv = (ImageView) view.findViewById(R.id.home_page_header_icon2_iv);
        home_page_header_name_tv = (TextView) mListHeader.findViewById(R.id.home_page_header_name_tv);
        home_page_header_gender_iv = (ImageView) mListHeader.findViewById(R.id.home_page_header_gender_iv);
        root_fl = (FrameLayout) view.findViewById(R.id.root_fl);
        home_page_tips = (LinearLayout) view.findViewById(R.id.home_page_tips);
        home_page_tips_invite_btn = (Button) view.findViewById(R.id.home_page_tips_invite_btn);
        home_page_tips_invite_btn.setOnClickListener(this);

        upload_notice_layout = (LinearLayout) view.findViewById(R.id.upload_notice_layout);
        upload_notice_layout.setOnClickListener(this);

        EventBus.getDefault().register(this);
    }

    @Override
    public void doInitDataes() {
        super.doInitDataes();
        baby_id = CommonUtils.getBabyId();
        mListView.getPullRootView().addFooterView(mFooterView);
        mAdapter = new HomeFragmentListAdapter(mActivity);
        mAdapter.setItemClickListener(this);
        mListView.setAdapter(mAdapter);
        if (baby_id.equals(PuTaoConstants.DEVAULT_BABY_ID)) {
            emptyView = LayoutInflater.from(mActivity).inflate(R.layout.layout_home_page_baby_empty, null);
            emptyView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            root_fl.addView(emptyView);
//            empty_header_add_baby_iv = (ImageView) emptyView.findViewById(R.id.empty_header_add_baby_iv);
            empty_add_baby_btn = (Button) emptyView.findViewById(R.id.empty_add_baby_btn);
            home_page_header_left3_btn = (Button) emptyView.findViewById(R.id.home_page_header_left3_btn);
            home_page_header_right3_btn = (Button) emptyView.findViewById(R.id.home_page_header_right3_btn);
//            empty_header_add_baby_iv.setOnClickListener(this);

            empty_invite_baby_btn = (Button) emptyView.findViewById(R.id.empty_invite_baby_btn);
            empty_add_baby_btn.setOnClickListener(this);
            home_page_header_left3_btn.setOnClickListener(this);
            home_page_header_right3_btn.setOnClickListener(this);
            empty_invite_baby_btn.setOnClickListener(this);
        } else {
            initBabyDataes();
        }
    }

    void LoadBabyRelationShip() {

        final ArrayList<FamilyItem> familyItems = new ArrayList<FamilyItem>();

        HashMap<String, String> params = new HashMap<String, String>();
        String babyId = CommonUtils.getBabyId();
        if (babyId.equals(PuTaoConstants.DEVAULT_BABY_ID)) {
            return;
        }
        Loger.d("LoadBabyRelationShip  babyId:" + babyId);
        params.put("baby_id", babyId);
        HttpRequestUtil.doHttpGetRequest(mActivity, PuTaoConstants.API_GET_BABY_RELATIONS, new RequestParams(HttpRequestUtil.buildHttpRequestParams(params)), new HttpRequestUtil.RequestResponseListener() {
            @Override
            public void success(int statuscode, String response) {
                Loger.d("get baby relation ship::::" + response);
                if (!StringHelper.isEmpty(response)) {
                    JSONObject data = HttpRequestUtil.getResponseData(response);
                    if (data != null) {
                        JSONArray list = data.optJSONArray("list");
                        if (list != null) {
                            String[] avr = new String[list.length()];
                            for (int i = 0; i < list.length(); i++) {
                                try {
                                    JSONObject o = list.getJSONObject(i);

                                    String id = o.optString("id");
                                    String name = o.optString("name");
                                    String tag = o.optString("tag");
                                    int is_admin = o.optInt("is_admin");
                                    int is_new = o.optInt("is_new");
                                    String avatar = o.optString("avatar");


                                    FamilyItem item = new FamilyItem();
                                    item.setId(id);
                                    item.setTag(tag);
                                    if (is_admin > 0) {
                                        name = name + "(管理员)";
                                        item.setAdmin(true);
                                    } else {
                                        item.setAdmin(false);
                                    }
                                    item.setName(name);
                                    if (is_new > 0) {
                                        item.setNew(true);
                                    } else {
                                        item.setNew(false);
                                    }
                                    item.setAvatar(avatar);

                                    familyItems.add(item);
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }

                            }
                            mAdapter.setAvatar(familyItems);
                            mAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }

            @Override
            public void failed(int statuscode, String response) {

            }
        });
    }

    /**
     * 初始化页面数据
     */
    public void initBabyDataes() {
        queryBabyInfo();
        refreshAlbumList();
    }


    private void queryBabyInfo() {
        HashMap<String, String> params = new HashMap<String, String>();
        String babyId = CommonUtils.getBabyId();
        params.put("baby_id", babyId);
        params.put("uid", CommonUtils.getUsrId());
        HttpRequestUtil.doHttpGetRequest(mActivity, PuTaoConstants.API_GET_BABY_SIMPLE_INFO,
                new RequestParams(HttpRequestUtil.buildHttpRequestParams(params)), new HttpRequestUtil.RequestResponseListener() {
                    @Override
                    public void success(int statuscode, String response) {
                        try {
                            Gson gson = new Gson();
                            RequestSimpleBabyInfoItem mRequestSimpleBabyInfoItem = (RequestSimpleBabyInfoItem) gson.fromJson(response,
                                    RequestSimpleBabyInfoItem.class);
                            if (mRequestSimpleBabyInfoItem.data.size() > 0) {
                                RequestSimpleBabyInfoItem.SimpleBabyInfoItem data = mRequestSimpleBabyInfoItem.data.get(0);
                                home_page_header_name_tv.setText(data.name);
                                if (data.sex.equals(Child.ChildSex.boy)) {
                                    home_page_header_gender_iv.setImageResource(R.drawable.all_icon_boy_border);
                                } else if (data.sex.equals(Child.ChildSex.girl)) {
                                    home_page_header_gender_iv.setImageResource(R.drawable.all_icon_girl_border);
                                } else {
                                    home_page_header_gender_iv.setImageResource(R.drawable.all_icon_unknow_border);
                                }
                                DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(BitmapHelper.getLoadingDrawable())
                                        .showImageOnFail(BitmapHelper.getLoadingDrawable()).cacheInMemory(true).cacheOnDisc(true)
                                        .considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
                                ImageLoader.getInstance().displayImage(data.avatar, home_page_header_icon_iv, options);
                                ImageLoader.getInstance().displayImage(data.avatar, home_page_header_icon2_iv, options);
                                CommonUtils.saveRelationShip(data.relationship);
                                CommonUtils.saveBabyAge(data.age);
                                CommonUtils.saveBabyName(data.name);
                                CommonUtils.saveCurBabyIconUrl(data.avatar);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void failed(int statuscode, String response) {
                    }
                });
    }

    private void refreshAlbumList() {
        preLast = 0;
        bFirstRefresh = true;
        curPage = 1;
        showLoading();
        mAdapter.clearData();
        queryAlbumList();
        LoadBabyRelationShip();
    }

    private void showLoading() {
        home_page_header_loading_pb.setVisibility(View.VISIBLE);
        home_page_header_circle_border.setVisibility(View.INVISIBLE);
    }

    private void hideLoading() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                home_page_header_loading_pb.setVisibility(View.INVISIBLE);
                home_page_header_circle_border.setVisibility(View.VISIBLE);
            }
        }, 1000);
    }

    /**
     * 查询时光轴相册列表
     */
    public void queryAlbumList() {
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("page", String.valueOf(curPage));
        params.put("baby_id", CommonUtils.getBabyId());
        HttpRequestUtil.doHttpGetRequest(mActivity, PuTaoConstants.API_GET_ALBUM_LIST,
                new RequestParams(HttpRequestUtil.buildHttpRequestParams(params)), new HttpRequestUtil.RequestResponseListener() {
                    @Override
                    public void success(int statuscode, String response) {
                        bFirstRefresh = false;
                        hideLoading();
                        try {
                            Gson gson = new Gson();
                            RequestAlbumListItem mMaterialInfoList = (RequestAlbumListItem) gson.fromJson(response, RequestAlbumListItem.class);
                            ArrayList<AlbumListItem> list = mMaterialInfoList.list;
                            if (list.size() == 0) {
                                mAdapter.notifyDataSetChanged();
                                mFooterView.findViewById(R.id.no_data_iv).setVisibility(View.GONE);
                                mFooterView.findViewById(R.id.more_data_ll).setVisibility(View.GONE);
                                return;
                            }
                            for (int i = 0; i < list.size(); i++) {
                                mAdapter.addData(list.get(i));
                            }
                            curPage = mMaterialInfoList.next_page;

                            if (curPage == -1) {
                                mFooterView.findViewById(R.id.no_data_iv).setVisibility(View.VISIBLE);
                                mFooterView.findViewById(R.id.more_data_ll).setVisibility(View.GONE);
                            } else {
                                mFooterView.findViewById(R.id.no_data_iv).setVisibility(View.GONE);
                                mFooterView.findViewById(R.id.more_data_ll).setVisibility(View.VISIBLE);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        mAdapter.notifyDataSetChanged();

                    }

                    @Override
                    public void failed(int statuscode, String response) {
                        Loger.d("response:" + response);
                        hideLoading();
                    }
                });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.home_page_header_left_btn:
            case R.id.home_page_header_left2_btn:
            case R.id.home_page_header_left3_btn:
                showLeft();
                break;
            case R.id.home_page_header_right_btn:
            case R.id.home_page_header_right2_btn:
            case R.id.child_icon:
                ActivityHelper.startActivity(mActivity, ActivityAlbumPhotoSelect.class);
                break;
//            case R.id.empty_header_add_baby_iv:
//                ActivityHelper.startActivity(mActivity, ActivityChildAdd.class);
//                break;
            case R.id.empty_add_baby_btn:
                ActivityHelper.startActivity(mActivity, ActivityChildAdd.class);
                break;
            case R.id.home_page_header_right3_btn:
                break;
            case R.id.home_page_cover_panel:
                hideLeft();
                break;
            case R.id.home_page_header_icon_iv:
                Bundle bundle = new Bundle();
                bundle.putString("child_id", CommonUtils.getBabyId());
                ActivityHelper.startActivity(mActivity, ActivityChildDetail.class, bundle);
                break;
            case R.id.baby_icon_nophoto_ll:
                ActivityHelper.startActivity(mActivity, ActivityAlbumPhotoSelect.class);
                break;
            case R.id.empty_invite_btn:
                if (popupwindow != null && popupwindow.isShowing()) {
                    popupwindow.dismiss();
                    popupwindow = null;
                } else {
                    popupwindow = PtInvitePopupWindow.Create(mActivity, this);
                    popupwindow.showAtLocation(v, Gravity.BOTTOM, 0, 0);
                }
                break;
            case R.id.home_page_tips_invite_btn:
                home_page_cover_panel.setVisibility(View.GONE);
                home_page_tips.setVisibility(View.GONE);
                ActivityHelper.startActivity(mActivity, ActivityInviteChildRelationSelect.class);
                break;

            case R.id.empty_invite_baby_btn:
                ActivityHelper.startActivity(mActivity, ActivityChildConnect.class);
                break;
            case R.id.upload_notice_layout:
                home_page_cover_panel.setVisibility(View.GONE);
                upload_notice_layout.setVisibility(View.INVISIBLE);
                break;
            default:
                break;

        }
    }

    public void showCoverPanel(boolean bShow) {
        if (bShow) {
            home_page_cover_panel.setVisibility(View.VISIBLE);
        } else {
            home_page_cover_panel.setVisibility(View.GONE);
        }
    }


    private void hideLeft() {
        ((AlbumHomeActivity) mActivity).showLeft(false);
    }

    private void showLeft() {
        ((AlbumHomeActivity) mActivity).showLeft(true);
    }

    public void onEvent(BasePostEvent event) {
        switch (event.eventCode) {
            case PuTaoConstants.EVENTBUS_UPLOAD_PHOTOS:

                Bundle bundle = event.bundle;
                String status = bundle.getString("status");
//                Loger.i("status:" + status);
                int total = bundle.getInt("total");
                int curIndex = bundle.getInt("curindex");
                int progress = bundle.getInt("progress");
                int success = bundle.getInt("success");
                int curProgress = ((curIndex - 1) * 100) + progress;
                int max = total * 100;
                if (FileUploadState.START.equals(status)) {
                    upload_status_ll.setVisibility(View.VISIBLE);
                    upload_status_pb.setMax(max);
                } else if (FileUploadState.UPLOADING.equals(status)) {
                    upload_status_pb.setProgress(curProgress);
                    upload_status_tv.setText("上传中..." + success + "/" + total);
                } else {
                    upload_status_ll.setVisibility(View.GONE);
                    refreshAlbumList();
                }
                break;
            case PuTaoConstants.EVENTBUS_ADD_CHILD_SUCCESS:
            case PuTaoConstants.EVENTBUS_SELECT_CHILD_SUCCESS:
                hideLeft();
                if (emptyView != null) {
                    root_fl.removeView(emptyView);
                }
                initBabyDataes();
                break;
            case PuTaoConstants.EVENTBUS_RELATE_BABY_SUCCESS:
                if (emptyView != null) {
                    root_fl.removeView(emptyView);
                }
                initBabyDataes();
                break;
            case PuTaoConstants.EVENTBUS_ADD_TAG_SUCCESS:
                initBabyDataes();
                break;
            case PuTaoConstants.EVENTBUS_MODIFY_CHILD_SUCCESS:
                queryBabyInfo();
                break;
            case PuTaoConstants.EVENTBUS_UPLOAD_LOCAL_PHOTOS: {
                if (mAdapter.getDataCount() == 0) {
                    showCoverPanel(true);
                    showFirstUploadTips();
                }
                Bundle bundle1 = event.bundle;
                LinkedList<FileInfo> list = (LinkedList<FileInfo>) bundle1.getSerializable("local_photo");
                AlbumListItem listItem = new AlbumListItem();
                ArrayList<AlbumListItem.AlbunPicItem> arrayList = new ArrayList<AlbumListItem.AlbunPicItem>();
                for (int i = 0; i < list.size(); i++) {
                    FileInfo info = list.get(i);
                    AlbumListItem.AlbunPicItem albunPicItem = new AlbumListItem.AlbunPicItem();
                    albunPicItem.picUrl = "file://" + info.getFilePath();
                    arrayList.add(albunPicItem);
                }
                listItem.timeName = "上传中";
                listItem.owner = CommonUtils.getRelationShip();
                listItem.albunPicItem = arrayList;
                listItem.photo_number = String.valueOf(arrayList.size());
                listItem.bLocalType = true;
                mAdapter.insertData(listItem);
                mAdapter.notifyDataSetChanged();
            }
            break;
            case PuTaoConstants.EVENTBUS_PHOTO_DELETED:
            case PuTaoConstants.EVENTBUS_REFRESH_ALBUM:
                refreshAlbumList();
                break;
            case PuTaoConstants.EVENTBUS_DELETE_LAST_CHILD:
                doInitDataes();
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }


    @Override
    public String getRelateionShip() {
        return "爸爸";
    }


    private void showFirstUploadTips() {
        upload_notice_layout.setVisibility(View.VISIBLE);
        int yPosition = -home_page_tips.getHeight();
        home_page_tips.setY(yPosition);
        home_page_tips.setVisibility(View.VISIBLE);
        ObjectAnimator animDown = ObjectAnimator.ofFloat(home_page_tips, "y",
                -home_page_tips.getHeight(), 450).setDuration(300);
        animDown.setInterpolator(new AccelerateInterpolator());
        AnimatorSet set = new AnimatorSet();
        set.setStartDelay(1500);
        set.playTogether(animDown);
        set.start();
    }
}
